<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        class Person {
            //1.公有属性
            name
            age
            //2.构造函数  里面的this就是实例对象
            constructor(name, age) {
                this.name = name
                this.age = age
            }
            //3.公有方法
            show() {
                console.log(this.name, this.age)
            }
        }

        //基于类 实例化对象
        const p = new Person('why', 18)
        p.show()
    </script>
</body>

</html>